home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 051-075 / scopedisk53 / memmometer / mm3.c < prev    next >
C/C++ Source or Header  |  1995-03-18  |  24KB  |  737 lines

  1. /* : ai=0 bk=0 ts=8 */
  2. #include "mm.h"
  3.  
  4. #define REDP 3L        /* workbench pen colors for Draw and RectFill */
  5. #define BLKP 2L
  6. #define WHTP 1L
  7. #define BLUP 0L
  8.  
  9. #define SOK        0x001f     /* memory allocation control masks */
  10. #define S1         0x0001
  11. #define S2         0x0002
  12. #define S4         0x0004
  13. #define S8         0x0008
  14. #define SA         0x0010
  15. #define C1         0xfffe
  16. #define C2         0xfffd
  17. #define C4         0xfffb
  18. #define C8         0xfff7
  19. #define CA         0xffef
  20.  
  21. #define EXTENSION  16L       /* allocation request increment */
  22.  
  23. #define EVENMASK 0x7ffffffe           /* used to prevent odd address traps */
  24. #define CLIHEIGHT 200L                             /* window scaling stuff */
  25. #define SIZEGAD 9L
  26. #define DRAGBAR 10L
  27. #define BORDER 2L
  28. #define WINW 16L                                   /* initial window width */
  29. #define WINH (long)(CLIHEIGHT - SIZEGAD - DRAGBAR)   /* initial win height */
  30. #define MINH 81L                              /* shortest allowable window */
  31. #define MAXH 576L                              /* longest allowable window */
  32. #define BART 1L                               /* title bar F text location */
  33. #define BARH (long)(WINH - SIZEGAD - DRAGBAR)                /* bar height */
  34. #define BARS (long)(BARH + 1)        /* number of memory items to allocate */
  35. #define BARB (long)(BARH + DRAGBAR - 1)        /* bottom of mercury column */
  36. #define BARE (long)(BARB + BORDER)              /* bar end E text position */
  37. #define BARW (long)(((WINW - (2 * BORDER)) / 3) - 1)  /* 3 memfragmometers */
  38. #define LEFT BORDER                   /* SLOW : since we're syncopated, we */
  39. #define MIDDLE (LEFT + BARW + 1)      /* SLOW-FAST : do it going from bar  */
  40. #define RIGHT (MIDDLE + BARW + 1)     /* FAST :to bar at an irregular pace */
  41. #define RTEXT - 4L        /* offset for three char E/F text from left edge */
  42. #define STARTVAL 64L    /* start by getting enough storage for a few frags */
  43.  
  44. /* typedef short BOOL */        /* this is in include/exec/types.h */
  45.  
  46. struct IntuitionBase *IntuitionBase ;
  47. struct Window *window ;
  48. struct IntuiMessage *message;
  49. /* struct IntuiMessage *GetMsg(); */        /* in functions.h */
  50.  
  51. struct GfxBase *GfxBase ;
  52.  
  53. extern void InitProjItems();        /* this stuff is in the mminit section */
  54. extern void InitSetupItems();
  55. extern void InitChipItems();
  56. extern void InitChipAItems();
  57. extern void InitSFItems();
  58. extern void InitSFAItems();
  59. extern void InitFastItems();
  60. extern void InitFastAItems();
  61. extern void InitMenu();
  62. extern void StartMenus();
  63.  
  64. BOOL p_mode = 0;              /* preset frags mode = 0, warps mode = 1 */
  65. long p_rate = 2;              /* preset sample interval, secs see menu */
  66. long p_chip = 512;            /* preset chip mem size, kbytes see menu */
  67. long p_chipa = 0;             /* preset chip mem address, kb  see menu */
  68. long p_sf = 512;              /* preset slowfast mem size, kb see menu */
  69. long p_sfa = 0x3000;          /* preset slowfast mem addr, kb see menu */
  70. long p_fast = 2;              /* preset fast mem size, mbytes see menu */
  71. long p_fasta = 2;             /* preset fast mem addr, mbytes see menu */
  72.  
  73. static BOOL mode;                    /* uninitialized for mode  menu */
  74. static long delayval;                /* uninitialized for delay menu */
  75. static long cmemsize;                /* uninitialized for chip  menu */
  76. static long cmembase;                /* uninitialized for chipa menu */
  77. static long sfmemsize;               /* uninitialized for sf    menu */
  78. static long sfmembase;               /* uninitialized for sfa   menu */
  79. static long fmemsize;                /* uninitialized for fast  menu */
  80. static long fmembase;                /* uninitialized for fasta menu */
  81.  
  82. static USHORT log ;
  83. static BOOL things_are_cool = TRUE ; /* tells when to close the window  */
  84. static BOOL intsig = FALSE ;         /* intuition message detector */
  85. static long chip[3], fast[3] ;       /* place to keep mem header pointers */
  86. static ULONG  *chunkv ;              /* demand allocated for frag chunks */
  87. static ULONG  *sizev ;               /* demand allocated for frag sizes */
  88. static ULONG  *csum ;                /* a col's height worth of checksums */
  89. static ULONG  *oldcsum ;             /* same height worth of old checksums */
  90. static USHORT *cell;                 /* 1 cell per pixel height of mercury */
  91. static long x1, x2 ;                 /* used to Draw() memometer segments */
  92. static long frags = STARTVAL ;       /* # of demand allocated frag items */
  93. static long warps = BARS ;           /* # of demand allocated column items */
  94. static long barh = BARH ;            /* EVEN #'d height of mercury column */
  95. static long barb = BARB ;            /* bottom position of mercury column */
  96.  
  97. /* struct RastPort *rp ; */          /* wonder why we don't need this... ? */
  98.  
  99. static struct TextAttr myfont = {
  100.    (STRPTR) "topaz.font",
  101.    TOPAZ_EIGHTY,
  102.    0,
  103.    0
  104. };
  105. /* E newsize gadget refresh text */
  106. static char ebuf[4] = " E " ;
  107. static struct IntuiText e_text = {
  108.    BLUP, WHTP,
  109.    JAM2,
  110.    0, BARE,
  111.    &myfont,
  112.    (UBYTE *)ebuf,
  113.    NULL
  114. };
  115. /* F title refresh text */
  116. static char fbuf[4] = " F " ;
  117. static struct IntuiText f_text = {
  118.    BLUP, WHTP,
  119.    JAM2,
  120.    0, BART,
  121.    &myfont,
  122.    (UBYTE *)fbuf,
  123.    &e_text
  124. };
  125. static struct NewWindow newwindow = {
  126.    0,                                        /* left edge */
  127.    10,                                       /* top edge */
  128.    WINW,                                     /* width */
  129.    WINH,                                     /* height */
  130.    0,                                        /* detail pen */
  131.    1,                                        /* block pen */
  132.    MENUPICK | NEWSIZE,                       /* messages */
  133. /* WINDOWDEPTH | WINDOWCLOSE */              /* don't use these gads */
  134.    WINDOWDRAG | WINDOWSIZING | SMART_REFRESH,   /* add a few gadgets */
  135.    NULL,                                     /* no custom gadgets */
  136.    NULL,                                     /* default checkmark */
  137.    (UBYTE *)"F",                             /* title */
  138.    NULL,                                     /* initialize this! */
  139.    NULL,                                     /* use screen bitmap */
  140.    WINW, MINH, WINW, MAXH,                   /* min and max sizes */
  141.    WBENCHSCREEN } ;                          /* use workbench screen */
  142.  
  143. void initmenus()
  144. {
  145.    (void) InitProjItems();                 /* Initialize the menu items */
  146.    (void) InitSetupItems();
  147.    (void) InitChipItems();
  148.    (void) InitChipAItems();
  149.    (void) InitSFItems();
  150.    (void) InitSFAItems();
  151.    (void) InitFastItems();
  152.    (void) InitFastAItems();
  153.    (void) InitMenu();
  154.    (void) StartMenus();
  155.    }
  156.  
  157. void handle_MENUPICK( class, code )
  158. unsigned long class;
  159. unsigned int code;
  160. {
  161.     unsigned int menunum, itemnum, subnum;
  162.  
  163.     if (code == MENUNULL) return;
  164.  
  165.     menunum = MENUNUM( code );
  166.     itemnum = ITEMNUM( code );
  167.     subnum  = SUBNUM( code );
  168.     switch( menunum ) {
  169.         case 0:
  170.         switch( itemnum ) {
  171.             case 0:
  172.             WindowToFront(window);
  173.             break;
  174.  
  175.             case 1:
  176.             WindowToBack(window);
  177.             break;
  178.  
  179.             case 2:
  180.             things_are_cool = FALSE;
  181.             break;
  182.             } /* end of switch ( Project itemnum ) */
  183.         break;
  184.  
  185.         case 1:
  186.         switch( itemnum ) {
  187.             case 0:
  188.             switch( subnum ) {
  189.                 case 0:
  190.                 mode = FALSE ;
  191.                 break;
  192.  
  193.                 case 1:
  194.                 mode = TRUE ;
  195.                 break;
  196.                 /* end of switch ( Mode subnum ) */
  197.                 }
  198.             break;
  199.             case 1:
  200.             switch( subnum ) {
  201.                 case 0:
  202.                 delayval = 36;
  203.                 break;
  204.  
  205.                 case 1:
  206.                 delayval = 72;
  207.                 break;
  208.  
  209.                 case 2:
  210.                 delayval = 180;
  211.                 break;
  212.  
  213.                 case 3:
  214.                 delayval = 360;
  215.                 break;
  216.                 /* end of switch ( Freq subnum ) */
  217.                 }
  218.             break;
  219.             /* end of switch ( Setup itemnum ) */
  220.             }
  221.         break;
  222.  
  223.         case 2:
  224.         switch( itemnum ) {
  225.             case 0:
  226.             cmemsize = 0x000000;
  227.             break;
  228.  
  229.             case 1:
  230.             cmemsize = 0x040000;
  231.             break;
  232.  
  233.             case 2:
  234.             cmemsize = 0x080000;
  235.             break;
  236.  
  237.             case 3:
  238.             cmemsize = 0x100000;
  239.             break;
  240.  
  241.             case 4:
  242.             cmemsize = 0x200000;
  243.             break;
  244.             }
  245.             /* end of switch ( Chip Size itemnum ) */
  246.         break;
  247.  
  248.         case 3:
  249.         switch( itemnum ) {
  250.             case 0:
  251.             cmembase = 0x000000;
  252.             break;
  253.  
  254.             case 1:
  255.             cmembase = 0x040000;
  256.             break;
  257.  
  258.             case 2:
  259.             cmembase = 0x080000;
  260.             break;
  261.  
  262.             case 3:
  263.             cmembase = 0x100000;
  264.             break;
  265.             }
  266.             /* end of switch ( Chip Addr itemnum ) */
  267.         break;
  268.  
  269.         case 4:
  270.         switch( itemnum ) {
  271.             case 0:
  272.             sfmemsize = 0x000000;
  273.             break;
  274.  
  275.             case 1:
  276.             sfmemsize = 0x080000;
  277.             break;
  278.  
  279.             case 2:
  280.             sfmemsize = 0x100000;
  281.             break;
  282.  
  283.             case 3:
  284.             sfmemsize = 0x180000;
  285.             break;
  286.             }
  287.             /* end of switch ( SF Size itemnum ) */
  288.         break;
  289.  
  290.         case 5:
  291.         switch( itemnum ) {
  292.             case 0:
  293.             sfmembase = 0xc00000;
  294.             break;
  295.  
  296.             case 1:
  297.             sfmembase = 0xc80000;
  298.             break;
  299.  
  300.             case 2:
  301.             sfmembase = 0xd00000;
  302.             break;
  303.  
  304.             case 3:
  305.             sfmembase = 0xd80000;
  306.             break;
  307.             }
  308.             /* end of switch ( SF Addr itemnum ) */
  309.         break;
  310.  
  311.         case 6:
  312.         switch( itemnum ) {
  313.             case 0:
  314.             fmemsize = 0x000000;
  315.             break;
  316.  
  317.             case 1:
  318.             fmemsize = 0x080000;
  319.             break;
  320.  
  321.             case 2:
  322.             fmemsize = 0x100000;
  323.             break;
  324.  
  325.             case 3:
  326.             fmemsize = 0x200000;
  327.             break;
  328.  
  329.             case 4:
  330.             fmemsize = 0x400000;
  331.             break;
  332.  
  333.             case 5:
  334.             fmemsize = 0x600000;
  335.             break;
  336.  
  337.             case 6:
  338.             fmemsize = 0x800000;
  339.             break;
  340.             }
  341.             /* end of switch ( Fast Size itemnum ) */
  342.         break;
  343.  
  344.         case 7:
  345.         switch( itemnum ) {
  346.             case 0:
  347.             fmembase = 0x200000;
  348.             break;
  349.  
  350.             case 1:
  351.             fmembase = 0x300000;
  352.             break;
  353.  
  354.             case 2:
  355.             fmembase = 0x400000;
  356.             break;
  357.  
  358.             case 3:
  359.             fmembase = 0x500000;
  360.             break;
  361.  
  362.             case 4:
  363.             fmembase = 0x600000;
  364.             break;
  365.  
  366.             case 5:
  367.             fmembase = 0x700000;
  368.             break;
  369.  
  370.             case 6:
  371.             fmembase = 0x800000;
  372.             break;
  373.  
  374.             case 7:
  375.             fmembase = 0x900000;
  376.             break;
  377.             }
  378.             /* end of switch ( Fast Addr itemnum ) */
  379.         break;
  380.         }
  381.         /* end of switch ( menunum ) */
  382. }
  383.  
  384. void wrack_sploot() /* this subprogram cashes in the chips in bad times */
  385.     {
  386.     if (log != 0) {
  387.         if (log & SA) {
  388.             (void) FreeMem(oldcsum, (long)(sizeof(ULONG) * warps)) ;
  389.             log = log & CA ;
  390.             }
  391.         if (log & S8) {
  392.             (void) FreeMem(csum, (long)(sizeof(ULONG) * warps)) ;
  393.             log = log & C8 ;
  394.             }
  395.         if (log & S4)  {
  396.             (void) FreeMem(sizev, (long)(sizeof(long) * frags)) ;
  397.             log = log & C4 ;
  398.             }
  399.         if (log & S2)  {
  400.             (void) FreeMem(chunkv, (long)(sizeof(long) * frags)) ;
  401.             log = log & C2 ;
  402.             }
  403.         if (log & S1) {
  404.             (void) FreeMem(cell, (long)(sizeof(USHORT) * warps)) ;
  405.             log = log & C1 ;
  406.             }
  407.         frags = 0;
  408.         warps = 0;
  409.         }
  410. }
  411.  
  412. void handle_NEWSIZE()        /* oh rats, the user found the size gadget... */
  413.     {
  414.     if (barh != window->Height)  {  /* cash in the old memory allocations  */
  415.         if (log & SA)  {
  416.             (void) FreeMem(oldcsum, (long)(sizeof(ULONG) * warps)) ;
  417.             log = log & CA ;
  418.             }
  419.         if (log & S8)  {
  420.             (void) FreeMem(csum, (long)(sizeof(ULONG) * warps)) ;
  421.             log = log & C8 ;
  422.             }
  423.         if (log & S1)  {
  424.             (void) FreeMem(cell, (long)(sizeof(USHORT) * warps)) ;
  425.             log = log & C1 ;
  426.             }
  427.         barh = window->Height - SIZEGAD - DRAGBAR ;  /* recalculate height */
  428.         barb = window->Height - SIZEGAD - 1 ; /* get new bar base position */
  429.         warps = barh + 1 ;       /* number of storage cells to be reserved */
  430.         if ((cell = (USHORT *)AllocMem((long)sizeof(USHORT) * warps,
  431.                                         MEMF_PUBLIC)) != 0L ) log = log | S1;
  432.         if ((csum = (ULONG *)AllocMem((long)sizeof(ULONG) * warps,
  433.                                         MEMF_PUBLIC)) != 0L ) log = log | S8;
  434.         if ((oldcsum = (ULONG *)AllocMem((long)sizeof(ULONG) * warps,
  435.                                         MEMF_PUBLIC)) != 0L ) log = log | SA;
  436.         if (log != SOK)  {      /* bail out if we didn't get an allocation */
  437.             wrack_sploot() ;
  438.             things_are_cool = FALSE ;     /* tell _main that we're leaving */
  439.             }
  440.         e_text.TopEdge = barb + BORDER ;        /* set the E text position */
  441.         }
  442. }
  443.  
  444. void handle_MESSAGES()  {
  445.     unsigned long class;
  446.     unsigned int code, qual;
  447.  
  448.     /* Wait (1L << window->UserPort->mp_SigBit); this is rediculous! */
  449.     while ((message=(struct IntuiMessage *)GetMsg(window->UserPort))
  450.                                                                 != 0L) {
  451.         class = message->Class ;
  452.         code = message->Code ;
  453.         qual = message->Qualifier ;
  454.         ReplyMsg ;
  455.         switch( class ) {
  456.             case NEWSIZE:
  457.             intsig = TRUE ;            /* resize when done here */
  458.             break ;
  459.  
  460.             case MENUPICK:
  461.             handle_MENUPICK( class, code ) ;    /* do menus ASAP */
  462.             break ;
  463.             }
  464.         }
  465. }
  466.  
  467. void memometer()                /* this subprogram draws the bar graphs */
  468.     {
  469.     long i;
  470.     long y;
  471.  
  472.     i = 0 ;
  473.     while ((i < barh) && (intsig == FALSE)) {
  474.         y = barb - i ;
  475.         SetAPen(window->RPort, (long)cell[i]);
  476.         Move(window->RPort, x1, y);
  477.         Draw(window->RPort, x2, y);
  478.         (void) handle_MESSAGES() ;  /* go see if the user wants anything */
  479.         i++ ;
  480.         }
  481. }
  482.  
  483. void shake()    /* this subprogram slings down the mercury column */
  484.     {
  485.     int i;
  486.  
  487.     for (i = 0; i < barh; i++)  {
  488.         cell[i] = REDP ;
  489.         }
  490. }
  491.  
  492. void lockout()  /* this subprogram renders a whole column in border colors */
  493.     {
  494.     (void) handle_MESSAGES() ;        /* go see if the user wants anything */
  495.     SetAPen(window->RPort, WHTP) ;    /* set in the border color */
  496.     RectFill(window->RPort, x1, (barb - barh + 1), x2, barb) ; /* fill in */
  497. }
  498.  
  499. void updatewarps( wf, membase, memseg )  /* this subprogram finds changes */
  500. short wf;
  501. long membase, memseg ;
  502.     {
  503.     register long i ;
  504.     register ULONG r ;
  505.     register ULONG delta ;
  506.     register ULONG *a ;
  507.  
  508.     if (memseg == 0) {
  509.         (void) lockout() ;
  510.         return ;
  511.         }
  512.     else (void) shake() ;
  513.  
  514.     delta = (ULONG)(memseg & EVENMASK) ;  /* try to avoid odd address trap */
  515.     r = (ULONG)(membase & EVENMASK) ;     /* prefer wrong address to death */
  516.     for (i = 0; i < barh; i++)  {
  517.         csum[i] = 0 ;
  518.         }
  519.     for (i = 0; i < barh; i++)  {
  520.         for (a = (ULONG *)r; a < (ULONG *)(r + delta); a++)  {
  521.             csum[i] += *a ;
  522.             }
  523.         if (csum[i] == 0) cell[i] = cell[i] & BLUP ;
  524.         if (csum[i] == oldcsum[i])  cell[i] = cell[i] & BLKP ;
  525.         oldcsum[i] = csum[i] ;
  526.         r += delta ;
  527.         }
  528.     (void) memometer();
  529. }
  530.  
  531. void updatescreen( wf, membase, memseg )
  532. short wf;
  533. long membase, memseg;
  534.     {
  535.     register long size ;
  536.     register struct MemHeader *hdr ;
  537.     register struct MemChunk *chunk ;
  538.     extern struct ExecBase *SysBase ;
  539.     register long *which ;                /* active memlist chunk pointer */
  540.     register long newlimit ;  /* number of chunks, incl 1 null chunk, + 1 */
  541.     register long newfrags ;  /* number of chunks, incl null chunks, + 1  */
  542.     long newsize ;  /* size of next request for chunkv/sizev memory, + 1  */
  543.     int i, j, k, l ;
  544.     int length ;       /* length is number of chunks to be processed, + 1 */
  545.     BOOL cf, nf ;      /* cf is "chip flag" nf is "null chunk found" flag */
  546.  
  547.     if (memseg == 0) {
  548.         (void) lockout() ;
  549.         return;
  550.         }
  551.     else (void) shake() ;
  552.  
  553.     for (i = 0; i < 3; i++) {
  554.         chip[i] = 0;
  555.         fast[i] = 0;
  556.         }
  557.     for (i = 0; i < frags; i++) {
  558.         chunkv[i] = 0;
  559.         sizev[i] = 0;
  560.         }
  561.     newfrags = 0 ;
  562.     newlimit = 0 ;
  563.     nf = FALSE;
  564.     Forbid() ;
  565.     hdr = (struct MemHeader *) SysBase->MemList.lh_Head ;
  566.     while (hdr->mh_Node.ln_Succ) {
  567.         if (hdr->mh_Attributes & MEMF_CHIP) {
  568.             which = chip ;
  569.             cf = TRUE;
  570.             }
  571.         else {
  572.             which = fast ;
  573.             cf = FALSE;
  574.             }
  575.         if (((cf == TRUE) && (wf == 0)) || ((cf == FALSE) && (wf > 0)))  {
  576.             for (chunk = hdr->mh_First; chunk; chunk = chunk->mc_Next) {
  577.                 if (which[1] < frags)  chunkv[which[1]++] = (unsigned long)chunk ;
  578.                 size = chunk->mc_Bytes ;
  579.                 if (which[2] < frags)  sizev[which[2]++] = (unsigned long)size;
  580.                 *which += size ;
  581.                 if (nf == FALSE)  {
  582.                     newlimit++ ;
  583.                     if (chunkv[newfrags] == NULL)  {
  584.                         nf = TRUE;
  585.                         }
  586.                     }
  587.                 newfrags++ ;
  588.             }
  589.         }
  590.         hdr = (struct MemHeader *)hdr->mh_Node.ln_Succ ;
  591.         }
  592.     Permit() ;
  593.     length = frags ;
  594.     if (newlimit < frags)  length = newlimit ;
  595.     for (i = 0; i < length; i++)  {
  596.         chunkv[i] -= membase;   /* chunkv is now array offset from base   */
  597.         sizev[i] += chunkv[i];  /* and sizev is now address of array top  */
  598.         chunkv[i] = chunkv[i] / memseg;  /* this is the number of pixels  */
  599.         sizev[i] = sizev[i] / memseg;       /* and this is the top pixel  */
  600.         if (chunkv[i] < 0) chunkv[i] = 0 ;  /* we do some bounds checking */
  601.         if (sizev[i] < 0) sizev[i] = 0 ;
  602.         if (chunkv[i] >= barh) chunkv[i] = barh - 1 ;
  603.         if (sizev[i] >= barh) sizev[i] = barh - 1 ;
  604.         if (sizev[i] - chunkv[i] < 0)  sizev[i] = chunkv[i] ;
  605.         j = chunkv[i] ; /* from now on it will be less confusing if */
  606.         k = sizev[i] ;  /* we assign some variables for this stuff  */
  607.         if (sizev[i] - chunkv[i] == 0)  {
  608.             cell[j] = cell[j] & BLUP ;
  609.             }
  610.         else  {
  611.             for (l = j; l < k; l++)  {
  612.                 cell[l] = cell[l] & BLKP ;
  613.                 }
  614.             }
  615.         }
  616.     (void) memometer();
  617.     newsize = frags ;
  618.     while (newsize < newlimit)  {
  619.         newsize += EXTENSION ;
  620.         }
  621.     if (newlimit > frags)  {
  622.         (void) FreeMem(chunkv, (long)(sizeof(long) * frags));
  623.         if ((chunkv = (unsigned long *)AllocMem((long)sizeof(long) * newsize,
  624.                                         MEMF_PUBLIC)) == 0L )  {
  625.             log = log & C2 ;
  626.             }
  627.         (void) FreeMem(sizev, (long)(sizeof(long) * frags));
  628.         if ((sizev = (unsigned long *)AllocMem((long)sizeof(long) * newsize,
  629.                                         MEMF_PUBLIC)) == 0L ) {
  630.             (void) FreeMem(chunkv, (long)(sizeof(long) * newsize));
  631.             log = log & C4 ;
  632.             }
  633.         if (log != SOK)  {
  634.             wrack_sploot() ;
  635.             things_are_cool = FALSE ;
  636.             }
  637.         else frags = newsize ;
  638.         }
  639. }
  640.  
  641. main() {
  642.     int i;
  643.     short wf;
  644.     long cmemseg;
  645.     long sfmemseg;
  646.     long fmemseg;
  647.     long membase;
  648.     long memseg;
  649.     long memsize;
  650.  
  651.  
  652.     log = 0 ;
  653.     if ((cell = (USHORT *)AllocMem((long)sizeof(USHORT) * BARS,
  654.                                         MEMF_PUBLIC)) != 0L ) log = log | S1;
  655.     if ((chunkv = (ULONG *)AllocMem((long)sizeof(ULONG) * STARTVAL,
  656.                                         MEMF_PUBLIC)) != 0L ) log = log | S2;
  657.     if ((sizev = (ULONG *)AllocMem((long)sizeof(ULONG) * STARTVAL,
  658.                                         MEMF_PUBLIC)) != 0L ) log = log | S4;
  659.     if ((csum = (ULONG *)AllocMem((long)sizeof(ULONG) * BARS,
  660.                                         MEMF_PUBLIC)) != 0L ) log = log | S8;
  661.     if ((oldcsum = (ULONG *)AllocMem((long)sizeof(ULONG) * BARS,
  662.                                         MEMF_PUBLIC)) != 0L ) log = log | SA;
  663.     if (log != SOK)  {
  664.         wrack_sploot() ;
  665.         Exit() ;
  666.         }
  667.     if ((IntuitionBase = (struct IntuitionBase *)OpenLibrary(
  668.             "intuition.library",33L)) != NULL &&
  669.             (window=OpenWindow(&newwindow)) != NULL)  {
  670.         if ((GfxBase = (struct GfxBase *)OpenLibrary(
  671.                 "graphics.library", 0L)) != NULL)  {
  672.             (void) initmenus();
  673.             /* rp = window->RPort ; */
  674.             wf = 0;
  675.             mode = p_mode ;
  676.             delayval = p_rate * 36 ;
  677.             cmemsize = p_chip << 10 ;
  678.             cmembase = p_chipa << 10 ;
  679.             sfmemsize = p_sf << 10 ;
  680.             sfmembase = p_sfa << 10 ;
  681.             if (p_fast >= 512)  fmemsize = p_fast << 10 ;
  682.             else fmemsize = p_fast << 20 ;
  683.             fmembase = p_fasta << 20 ;
  684.             while (things_are_cool == TRUE) {
  685.                 cmemseg = cmemsize / barh ;
  686.                 sfmemseg = sfmemsize / barh ;
  687.                 fmemseg = fmemsize / barh ;
  688.                 switch ( wf ) {
  689.                     case 0:
  690.                     x1 = LEFT ;
  691.                     membase = cmembase ;
  692.                     memseg = cmemseg ;
  693.                     memsize = cmemsize ;
  694.                     break;
  695.  
  696.                     case 1:
  697.                     x1 = MIDDLE ;
  698.                     membase = sfmembase ;
  699.                     memseg = sfmemseg ;
  700.                     memsize = sfmemsize ;
  701.                     break;
  702.  
  703.                     case 2:
  704.                     x1 = RIGHT ;
  705.                     membase = fmembase ;
  706.                     memseg = fmemseg ;
  707.                     memsize = fmemsize ;
  708.                     break;
  709.                     }
  710.                 x2 = x1 + BARW ;
  711.                 if (mode == TRUE)  {
  712.                     (void) updatewarps( wf, membase, memseg ) ;
  713.                     }
  714.                 if (mode == FALSE)  {
  715.                     (void) updatescreen( wf, membase, memseg ) ;
  716.                     }
  717.                 if (intsig == TRUE)  {
  718.                     handle_NEWSIZE() ;
  719.                     intsig = FALSE ;
  720.                     }
  721.                 if (wf == 2)  {
  722.                     PrintIText(window->RPort,&f_text,RTEXT,0L) ;
  723.                     Delay(delayval) ;
  724.                     }
  725.                 wf++ ;
  726.                 if (wf >= 3)  wf = 0 ;
  727.                 } /* end of while ( things_are_cool) */
  728.             wrack_sploot() ;
  729.             }
  730.         if (GfxBase)    CloseLibrary(GfxBase) ;
  731.         }
  732.     if (window)         CloseWindow(window) ;
  733.     if (IntuitionBase)  CloseLibrary(IntuitionBase) ;
  734. }
  735. _cli_parse() {}
  736. _wb_parse() {}
  737.